package classpath
import (
	"os"
	"strings"
)
/*
先定一个接口表示类路径项
*/

//常量pathListSeparator是string类型，从南方路径分隔符
const pathListSeparator = string(os.PathSeparator)

type Entry interface{
	//readClass()方法负责寻找和加载class文件
	readClass(className string) ([]byte,Entry,error)
	//String() 方法的作用相当于JAVA中的toString(),用于返回变量的字符串表示
	String() string 
}
func newEnry(path string)  Entry{
	if strings.Contains(path,pathListSeparator){
		return newCompositeEntry(path);
	}
	if strings.HasSuffix(path,"*") {
		return newWildcardEntry(path);
	}
	if strings.HasSuffix(path,".jar") || strings.HasSuffix(path,".JAR") ||strings.HasSuffix(path,".zip") || strings.HasSuffix(path, ".ZIP") {
		return newZipEntry(path)
	}
	
	return newDirEntry(path)
}